#include "HufArc.h"
__HufTree * mkH_TInit (FILE * fileToRead)
{

	int i = 0;
	int rc = 0;
	int count = 1;
	int firstElement = 0;
	__HufTree ** H_T = (__HufTree**) calloc (256, sizeof(__HufTree*));
	__HufTree * head = NULL;
	//HTlist * htListTale = NULL;
	unsigned char buf[] = "";

	H_T = (__HufTree **) calloc (256,sizeof(__HufTree*));
	if (!H_T)
		cl_exit (HUF_TREE_INIT,MEMORY_ERR);
	while ((rc = fread (buf,sizeof(char),SIZE_T_1,fileToRead)) == 1)
	{
		if (!H_T[buf[0]])
			H_T[buf[0]] = (__HufTree *) calloc (1,sizeof(__HufTree));
		if (!H_T[buf[0]])
			cl_exit (HUF_TREE_INIT,MEMORY_ERR);
		if (H_T [buf[0]]->count == 0)
			H_T [buf[0]]->alpha = buf[0];
		H_T [buf[0]]->count++;
	}
	H_T = SortHuffTree (H_T);
	head = MakeHufTree (H_T);
	return head;
}